<script type="text/javascript">
<!--
$(function() {
	$(".soluong").keydown(function(e) {
		arr_key = new Array();
		arr_key[8]=8;
		arr_key[9]=9;
		arr_key[35]=35;
		arr_key[36]=36;
		arr_key[37]=37;
		arr_key[39]=39;
		arr_key[46]=46;
        if ( arr_key[e.keyCode]!==undefined) {}
        else {
            if (e.keyCode < 48 || e.keyCode > 57 ) {
                e.preventDefault(); 
            }   
        }});
});
//-->
</script>
<?php
if(!empty($chitieungays) && !empty($hanghoas))
{
$numhh = count($hanghoas); 
?>

<h2 style="text-align:center">Nhập kết quả bán hàng lưu động</h2>
<!--<h3>Ngày <?php echo date('d-m-Y',strtotime($ngay));?></h3-->


<table id ='tables'>
<tr>
<th rowspan=2>STT</th>
<th rowspan=2>Đội</th>
<th rowspan=2>Địa Điểm</th>
<th rowspan=2>Ngày</th>
<th rowspan=2>Thành viên tham gia</th>
<th colspan=<?php echo $numhh?>>Chỉ tiêu</th>
<th rowspan=2>Ghi chú</th>
</tr>
<tr>
<?php foreach ($hanghoas as $keyhh =>$valhh):?>
<th><?php echo $valhh ?></th>
<?php endforeach;?>
</tr>
<?php
	$i=0; 
	 foreach ($chitieungays as $chitieungay):
	  $i++;
?>
<tr>
<td><? echo $i?></td>
<?php echo $form->input('idkh',array('type'=>'hidden','value'=>$chitieungay['Kehoachbhld']['id']))?>
<?php echo $form->input('nhanvien_id',array('type'=>'hidden','value'=>$chitieungay['Kehoachbhld']['nhanvien_id']))?>
<td><?php echo $chitieungay['Kehoachbhld']['tendoi']?></td>
<td><?php echo $chitieungay['Kehoachbhld']['diadiem']?></td>
<td><?php echo date('d-m-Y',strtotime($chitieungay['Kehoachbhld']['thoigian']))?></td>
<td><?php echo $chitieungay['Kehoachbhld']['nhansu']?></td>
<?php foreach ($hanghoas as $keyhh =>$valhh):
		foreach ($chitieungay['Chitieungay'] as $ctngay)
		{
			if($ctngay['hanghoa_id']==$keyhh)
			{
				echo '<td><input class="soluong" name=data[Chitieungay][hanghoa]['.$ctngay['id'].'] value='.$ctngay['ketqua'].'></td>';
			}	
		}
	endforeach;?>
<td><?php echo $chitieungay['Kehoachbhld']['ghichu']?></td>
<?php endforeach;?>
</tr>
</table>
<?php echo $form->end('  Lưu  ');
}
else 
{
	echo "<h2>Không có kế hoạch BHLĐ ngày ".date('d-m-Y')."</h2>";
}
?>
